package facade;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import bean.Departamento;


@Stateless
public class DepartamentoFacade<T> extends AbstractFacade<Departamento> {

	@PersistenceContext(unitName = "Exemplo001PU")
	private EntityManager em;
	
	@Override
	protected EntityManager getEntityManager() {
		return em;
	}
	
	public DepartamentoFacade() {
		super(Departamento.class);
	}
	
	public List<T> buscar(String dep) {
		Query query = getEntityManager().createNamedQuery("Departamento.findByParteNomDep");
		query.setParameter("nomDep", "%" + dep + "%");
		return query.getResultList();
	}
}
